package com.kaigejava.juc.cas;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @author kaigejava
 * CAS 演示代码1
 */
public class CasDemo1 {
    public static void main(String[] args) {
      /*  AtomicInteger i = new AtomicInteger(1);
        System.out.println(i.compareAndSet(1,2020)+"\t 运行后。当前i的值为："+i.get());
        System.out.println(i.compareAndSet(1,1024)+"\t 运行后。当前i的值为："+i.get());
        System.out.println(i.compareAndSet(2020,1024)+"\t 运行后。当前i的值为："+i.get());

        AtomicInteger atoInteger = new AtomicInteger(0);
        atoInteger.getAndIncrement();*/
        Integer i =  new Integer(1000);
        Integer j =  new Integer(1000);
       // System.out.println(i == j);
        int ix = 1000;
        int jx = 1000;
        int iix = new Integer(1000);
      /*  System.out.println(ix ==jx );
        System.out.println(jx ==iix );*/
      //  System.out.println(j.intValue() == jx);

       int ixxx =  say();
        System.out.println("ixxx"+ixxx);

    }

    private static int say() {
      //  int x = 1/0;
        try{
            System.out.println(0);
            return 0;
        }catch (Exception e){
            System.out.println(-1);
            return -1;
        }finally {
            System.out.println(1);
        }
    }
}
